Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Correct the definition of an expression in the user guide #14750

Merged
merged 4 commits into from
Mar 21, 2024

Conversation

MarcoGorelli
Copy link
Collaborator

@MarcoGorelli MarcoGorelli commented Feb 28, 2024

I hope it's OK to suggest this change - it's been bugging me for a bit, and trying to translate the Polars API to the pandas API I kept coming up against this

If we consider the expression expr = pl.sum_horizontal('a', 'b').abs(), then it roughly translates to

def expr(df):
   return (df['a'] + df['b']).abs()

So the input is a dataframe, not a series. The output is always a Series, which is why you can keep chaining expressions - they just keep acting on the output Series from the previous step


EDIT: I think I also heard Orson describe expressions in these terms, but can't find the message now

@github-actions github-actions bot added documentation Improvements or additions to documentation python Related to Python Polars rust Related to Rust Polars labels Feb 28, 2024
@MarcoGorelli MarcoGorelli marked this pull request as ready for review February 28, 2024 22:00
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good adjustment, thanks!

@stinodego stinodego changed the title docs: correct definition of expressions (from fn(Series) -> Series to fn(DataFrame) -> Series) docs: Correct the definition of an expression in the user guide Mar 21, 2024
@stinodego stinodego merged commit ba9117a into pola-rs:main Mar 21, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants